function redirectToSsoLoginPage(sevice) {
  console.log('window.location.href', window.location.href);
  if (process.env.VUE_APP_IS_LOCAL === 'true') {
    const serviceUrl = encodeURIComponent(sevice);
    window.location.href = `${
      process.env.VUE_APP_CAS_BASE_URL
    }/web-auth/login?service=${serviceUrl}`;
  } else {
    window.location.href = `${process.env.VUE_APP_UNIFIE_LOGIN_URL}`;
  }
}

function getUrlParam(paraName) {
  const url = document.location.toString();
  const arrObj = url.split('?');
  if (arrObj.length > 1) {
    const arrPara = arrObj[1].split('&');
    for (let i = 0; i < arrPara.length; i += 1) {
      const arr = arrPara[i].split('=');
      if (arr != null && arr[0] === paraName) {
        return arr[1];
      }
    }
  }
  return '';
}
const SSO = {
  getUrlParam,
  redirectToSsoLoginPage,
};

export default SSO;